home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / BUS / TMCM Software and Labs.sit / Software for TMCM 7_95 / Files for Lab 13 / DrawGraphs < prev    next >
Text File  |  1995-07-08  |  1KB  |  55 lines

  1. {
  2.    This program draws the graphs of two functions,
  3.    y = x^2/8  and  y = x^3/64,  on the same set of
  4.    axes.
  5.  
  6.    Your assignment is to modify the program so that
  7.    the two graphs will be drawn simultaneously by two 
  8.    separate turtles.
  9. }
  10.  
  11. SUB Axes    { Subroutine for drawing the axes }
  12.   PenUp
  13.   MoveTo(-8,0)
  14.   PenDown
  15.   MoveTo(8,0)
  16.   PenUp
  17.   MoveTo(0,-8)
  18.   PenDown
  19.   MoveTo(0,8)
  20. END SUB
  21.  
  22. SUB Graph1   { Subroutine for drawing the graph of y = x^2/8 }
  23.   DECLARE x,y
  24.   PenUp
  25.   x := -8
  26.   y := x^2 / 8
  27.   MoveTo(x,y)
  28.   PenDown
  29.   LOOP
  30.     x := x + 0.5
  31.     EXIT IF x > 8
  32.     y := x^2 / 8
  33.     MoveTo(x,y)
  34.   END LOOP
  35. END SUB
  36.  
  37. SUB Graph2   { Subroutine for drawing the graph of y = x^3/64 }
  38.   DECLARE x,y
  39.   PenUp
  40.   x := -8
  41.   y := x^3 / 64
  42.   MoveTo(x,y)
  43.   PenDown
  44.   LOOP
  45.     x := x + 0.5
  46.     EXIT IF x > 8
  47.     y := x^3 / 64
  48.     MoveTo(x,y)
  49.   END LOOP
  50. END SUB
  51.  
  52. Axes       { Draw the Axes. }
  53. Graph1     { Draw the first graph. }
  54. Graph2     { Then draw the second graph. }
  55. HideTurtle { since the picture looks better without it. }